package org.example.lethear.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 悄悄话设置实体类
 */
@Entity
@Table(name = "whisper_settings")
@Data
@EqualsAndHashCode(callSuper = false)
@EntityListeners(AuditingEntityListener.class)
public class WhisperSettings {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "user_id", nullable = false, unique = true)
    private Long userId;
    
    @Column(name = "allow_anonymous", columnDefinition = "TINYINT DEFAULT 1")
    private Integer allowAnonymous; // 0-不允许，1-允许
    
    @Column(name = "need_review", columnDefinition = "TINYINT DEFAULT 0")
    private Integer needReview; // 0-不需要，1-需要
    
    @Column(name = "max_daily_count", columnDefinition = "INT DEFAULT 50")
    private Integer maxDailyCount;
    
    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;
    
    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;
    
    // 构造方法
    public WhisperSettings() {}
    
    public WhisperSettings(Long userId) {
        this.userId = userId;
        this.allowAnonymous = 1;
        this.needReview = 0;
        this.maxDailyCount = 50;
    }
    
    public WhisperSettings(Long userId, Integer allowAnonymous, Integer needReview, Integer maxDailyCount) {
        this.userId = userId;
        this.allowAnonymous = allowAnonymous;
        this.needReview = needReview;
        this.maxDailyCount = maxDailyCount;
    }
} 